<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'资源添加', styles:'bootstrap,font-awesome,animate,style,dtvalidate,layer,chosen'}){%>
    <style type="text/css">
        body{padding-top:10px;}
    </style>
    <%}%>
</head>
<body>

<!-- START 内容部分 -->
<div class="container" >
    <form class="form-horizontal" id="info-form" method="post" autocomplete="off" style="margin: auto">
        <input type="hidden" name="id" value="${payment.id}">

        <div class="form-group" style="margin-top: 20px">
            <label class=" control-label col-sm-2" style="max-width: 100px">是否收发票</label>
            <div class="col-sm-6" style="max-width: 400px;">
                <select  id="produceIsBill" name="produceIsBill" class="form-control">
                    <option value="否" <%if(payment.produceIsBill == '否'){print("selected");}%>>否</option>
                    <option value="是" <%if(payment.produceIsBill == '是'){print("selected");}%>>是</option>
                </select>
            </div>
        </div>
        <div class="form-group " style="margin-top: 20px">
            <label class=" control-label col-sm-2" style="max-width: 100px">发票凭证</label>
            <div class="col-sm-6" style="max-width: 400px;">
                <a class="club-import-btn ">
                    <input type="file" id="importSession" name="importSession">
                </a>
                <input type="hidden" name="produceBillFile" id="produceBillFile" value="${payment.produceBillFile}">
            </div>
        </div>
        <div class="form-group">
            <label class=" control-label col-sm-2" style="max-width: 100px">出货时间</label>
            <div class="col-sm-5">
                <input type="text" id="produceOutTime" value="${payment.produceOutTime}" name="produceOutTime" class="form-control">
            </div>
        </div>
        <div class="form-group " style="margin-top: 20px">
            <label class=" control-label col-sm-2" style="max-width: 100px">备注</label>
            <div class="col-sm-6" style="max-width: 400px;">
                <textarea id="produceReason" name="produceReason" class="form-control" rows="3">${payment.produceReason}</textarea>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="save-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </div>
    </form>
</div>
<!-- END 内容部分 -->

<!-- START 公共脚本 -->
<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,dtvalidate,dtvalidate-lang-zh_cn,laydate,layer,chosen,chosen-demo'}){}%>
<!-- END 公共脚本 -->
<script>
    laydate.render({
        elem: '#produceOutTime' //指定元素
        ,trigger: 'click'
    });
    var cvalidator;
    $(function(){

        //初始化验证器
        cvalidator = $.fn.dlshouwen.validator.init($('#info-form'));
        //提交表单
        $('.save-btn').on('click',function(){
            var index=layer.load();
            //数据提交
            $.post('/sea/supply/produce/payment/usave.do',$('#info-form').serialize(),function(data){
                if( data.ok ){
                    parent.layer.msg(data.msg,{icon:1,time:1500,shade: [0.8, '#393D49']}, function(){
                        layer.close(index);
                        parent.$portTable.bootstrapTable('refresh');
                        parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
                    });
                }else{
                    layer.close(index);
                    parent.layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
                }
            });
        });

        //返回
        $('.return-btn').on('click',function(){
            parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭弹窗
        });
    });


    $("#importSession").on("change",function(){
        var formFile = new FormData($('#info-form')[0]);
        var index=layer.load(1, {
            shade: [0.1,'#fff'],
            zIndex : 1111//0.1透明度的白色背景
        });
        $.ajax({
            url: "/upload/uploadFile",
            data: formFile,
            type: "post",
            processData: false,//用于对data参数进行序列化处理 这里必须false
            contentType: false, //必须
            success: function (data) {
                console.log(data);
                if(data.ok){
                    parent.layer.msg("上传成功！",{icon: 0,time:1500,shade: [0.8, '#393D49']});
                    $("#produceBillFile").val(data.data);
                    layer.close(index);
                }else{
                    parent.layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
                    layer.close(index);
                }
            },
        });
    });
</script>
</body>
</html>